package com.skyable.device.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skyable.device.entity.DeviceBindInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @author GaoYuan
 * @date 2019/11/15 13:56
 * @desc
 */
@Mapper
public interface DeviceBindInfoMapper extends BaseMapper<DeviceBindInfo> {

    /**
     * 创建设备绑定表
     * @param domainId
     * @return
     */
    @Update({
            " CREATE TABLE IF NOT EXISTS  ${domainId}_bind_info ( " +
                    " id bigint(20) NOT NULL AUTO_INCREMENT " +
                    " uid bigint(20) NOT NULL, " +
                    " physical_device_id varchar(32) NOT NULL, " +
                    " user_role int(8) NOT NULL DEFAULT '0', " +
                    " create_time datetime DEFAULT NULL, " +
                    " modify_time datetime DEFAULT NULL, " +
                    " PRIMARY KEY (id), " +
                    " KEY (`physical_device_id`) USING HASH " +
                " ) ENGINE=InnoDB DEFAULT CHARSET=utf8; "
    })
    int createDeviceBindInfoTable(@Param("domainId") Long domainId);

}
